import mongoose from 'mongoose';
import { formatDateByNow } from '~/utils/util.date';

export interface ISiteConfig extends mongoose.Document {
	icon: string;
	title: string;
	description: string;
	keywords: string;
	domain: string;
	globalStyle: string;
	globalScript: string;
	about: string;
	createdAt?: string;
	updatedAt?: string;
}

// 站点信息
const SiteConfigSchema = new mongoose.Schema<ISiteConfig>(
	{
		icon: {
			type: String,
			required: true,
		},
		title: {
			type: String,
			required: true,
		},
		description: {
			type: String,
			required: true,
		},
		keywords: {
			type: String,
			required: true,
		},
		domain: {
			type: String,
			required: true,
		},
		globalStyle: {
			type: String,
		},
		globalScript: {
			type: String,
		},
		about: {
			type: String,
		},
		createdAt: {
			type: String,
			default: formatDateByNow(),
		},
		updatedAt: {
			type: String,
			default: formatDateByNow(),
		},
	},
	{
		collection: 'site_config',
	}
);

export const SiteConfigModel = mongoose.model('SiteConfig', SiteConfigSchema);
